import org.apache.commons.collections.comparators.ComparatorChain;

import java.util.Comparator;

/**
 * Created by John on 10/23/2014.
 */
public class HandComparator{

    HandComparator() {
    }

    public static ComparatorChain getChain() {
        chain.addComparator(combinationsCompare);
        chain.addComparator(cardCompare);
        return chain;
    }

    final static ComparatorChain chain = new ComparatorChain();

    public static Comparator<Hand> combinationsCompare = new Comparator<Hand>() {
        @Override
        public int compare(Hand o1, Hand o2) {
            Combination o1Combination = Game.findCombination(o1);
            Combination o2Combination = Game.findCombination(o2);
            return o2Combination.getLevelOfCard().getValue() - o1Combination.getLevelOfCard().getValue();
        }
    };
    public static Comparator<Hand> cardCompare = new Comparator<Hand>() {
        @Override
        public int compare(Hand o1, Hand o2) {
            Combination o1Combination = Game.findCombination(o1);
            Combination o2Combination = Game.findCombination(o2);

            return o2Combination.getRankCard().getLevel().getValue() - o1Combination.getRankCard().getLevel().getValue();
        }
    };
}
